package java8;

import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;

/**
 * Created by bruce on 2015/3/9.
 */
public class ListMain {
    public static void main(String[] args) {
        final List<String> lst = new ArrayList<>();
        lst.add("a");
        lst.add("b1");
        lst.add("cdf");
        lst.add("dggh");


        ListIterator lit = lst.listIterator();

        p(lit.next());
        p(lit.next());

        p(lit.previous());

        int sum = lst.stream()
                .filter(w -> w.equalsIgnoreCase("cdf"))
                .mapToInt(w -> w.toUpperCase().length())
                .sum();

        p(sum);

    }

    static private void p(Object o) {
        System.out.println(o);
    }
}
